package com.ruoyi.web.controller.prevention;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.PreventionPlanPerformance;
import com.ruoyi.system.service.PreventionPlanPerformanceService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("preventionPlanPerformance")
public class PreventionPlanPerformanceController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private PreventionPlanPerformanceService preventionPlanPerformanceService;

    /**
     * 分页查询
     * @param preventionPlanPerformance 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(PreventionPlanPerformance preventionPlanPerformance) {
        startPage();
        List<PreventionPlanPerformance> preventionPlanPerformanceList = this.preventionPlanPerformanceService.queryByPage(preventionPlanPerformance);
        return getDataTable(preventionPlanPerformanceList);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Integer id) {
        return AjaxResult.success(this.preventionPlanPerformanceService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param preventionPlanPerformance 实体
     * @return 新增结果
     */
    @PostMapping("/create")
    public AjaxResult add(@RequestBody PreventionPlanPerformance preventionPlanPerformance) {
        return AjaxResult.success(this.preventionPlanPerformanceService.insert(preventionPlanPerformance));
    }

    /**
     * 编辑数据
     *
     * @param preventionPlanPerformance 实体
     * @return 编辑结果
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody PreventionPlanPerformance preventionPlanPerformance) {
        return AjaxResult.success(this.preventionPlanPerformanceService.update(preventionPlanPerformance));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public AjaxResult deleteById(Integer id) {
        return AjaxResult.success(this.preventionPlanPerformanceService.deleteById(id));
    }






















}

